(function (n, s) {
    typeof exports == "object" && typeof module < "u" ? s(exports) : typeof define == "function" && define.amd ? define(["exports"], s) : (n = typeof globalThis < "u" ? globalThis : n || self, s(n.WeighProtocols = {}))
})(this, function (n) {
    "use strict";

    class s {
        weight = [];
        start = 2;
        isAscii;
        finish = !1;
        startIndex = 0;
        static MAX_POTOCOL_LENGTH = 30;

        constructor(t) {
            this.isAscii = t
        }

        add(t) {
            this.isAscii && t < 0 || this.finish || (t === this.start ? this.weight[0] === this.start ? this.finish = !0 : this.weight = [t] : this.weight.length > s.MAX_POTOCOL_LENGTH ? this.weight = [t] : this.weight.push(t))
        }

        isComplete() {
            return this.finish
        }

        parseWeight() {
            const t = Number(this.doParseWeight(this.weight.filter(e => e !== this.start)));
            return this.weight = [], this.finish = !1, t
        }
    }

    class l extends s {
        constructor() {
            super(!0)
        }

        doParseWeight(t) {
            const e = Number.parseInt(String.fromCodePoint(t[9])), i = t.map(r => String.fromCodePoint(r)).slice(2, 9);
            return i.splice(i.length - e, 0, "."), i.join("")
        }

        get name() {
            return "顶松1705通讯方式(6)"
        }
    }

    class u extends s {
        constructor() {
            super(!0)
        }

        doParseWeight(t) {
            return String.fromCodePoint(...t.slice(0, 7)).trim()
        }

        get name() {
            return "HBM通用协议"
        }
    }

    class g extends s {
        constructor() {
            super(!1), this.start = -1
        }

        doParseWeight(t) {
            const e = t[0].toString(16);
            return (e === "31" || e === "21" ? "-" : "+") + t[t.length - 1].toString(16) + t[t.length - 1 - 1].toString(16) + t[t.length - 1 - 1 - 1].toString(16)
        }

        get name() {
            return "恒天通用协议"
        }
    }

    class h extends s {
        constructor() {
            super(!0)
        }

        doParseWeight(t) {
            const e = this.parseDigitsPosition(t[0]), i = this.parseNegative(t[1]),
                r = t.slice(3, 9).map(o => String.fromCodePoint(o));
            return r.unshift(i), r.splice(r.length - e, 0, "."), r.join("")
        }

        parseDigitsPosition(t) {
            const e = t.toString(2), i = [-1, -1, -1];
            e.length >= 3 ? (i[0] = Number.parseInt(e.slice(-1, e.length)), i[1] = Number.parseInt(e.slice(-2, -1)), i[2] = Number.parseInt(e.slice(-3, -2))) : e.length == 2 ? (i[0] = Number.parseInt(e.slice(-1, e.length)), i[1] = Number.parseInt(e.slice(-2, -1)), i[2] = 0) : e.length == 1 && (i[0] = Number.parseInt(e.slice(-1, e.length)), i[1] = 0, i[2] = 0);
            const r = i.map(o => o.toString()).join();
            return r == "110" ? 1 : r == "001" ? 2 : r == "101" ? 3 : r == "011" ? 4 : r == "111" ? 5 : 0
        }

        parseNegative(t) {
            const e = t.toString(2);
            return e.length >= 2 && e.slice(-2, -1) == "1" ? "-" : ""
        }

        get name() {
            return "托利多协议"
        }
    }

    class a extends s {
        constructor() {
            super(!0), this.start = 10
        }

        doParseWeight(t) {
            return String.fromCodePoint(...t.slice(6, 14)).split(" ").join("")
        }

        get name() {
            return "金钟XK3102K"
        }
    }

    class f extends s {
        constructor() {
            super(!0)
        }

        doParseWeight(t) {
            const e = t.filter(o => o !== 2 && o !== 3 && o !== 255), i = Number.parseInt(String.fromCodePoint(e[7])),
                r = e.slice(0, 7).map(o => String.fromCharCode(o));
            return r.splice(r.length - i, 0, "."), r.join("")
        }

        get name() {
            return "耀华通用协议"
        }
    }

    class m extends s {
        constructor() {
            super(!0), this.start = 61
        }

        doParseWeight(t) {
            return t.reverse(), String.fromCodePoint(...t)
        }

        get name() {
            return "耀华XK3190-A9"
        }
    }

    n.DS_1705Protocol = l, n.HBMWeightProtocol = u, n.HTWeightProtocol = g, n.TLDWeightProtocol = h, n.XK3102K = a, n.YaoWeightProtocol = f, n.YaoXk3190A9 = m, Object.defineProperty(n, Symbol.toStringTag, {value: "Module"})
});
